* Table D1: Narrow market power

********************************************************************************
************************** Prepare data ****************************************
********************************************************************************

import delimited "${data_narrow_market_power}", clear 

********************************************************************************
************************** Prepare table ***************************************
********************************************************************************
cap file close sumstat
file open sumstat using "${tableD1}", write replace

file write sumstat "\begin{tabular}{c c c}\hline\hline" _n
file write sumstat "Fraction subject to market power (\%) & Assigned under preference flip & Increase relative to \SRDA (\%)\\ " _n
file write sumstat "(1) & (2) & (3) \\ \hline" _n

forvalues i = 100(-10)10 {
	qui sum assigned if fraction == `i'
	local assigned`i': display %12.0fc r(mean)
	
	qui sum change if fraction == `i'
	local change`i': display %12.1fc r(mean)
	
	file write sumstat " `i' & `assigned`i'' & `change`i'' \\" _n
}

file write sumstat "\hline\hline \multicolumn{3}{p{16cm}}{{\it Notes}: The table presents the number of assigned applicants under the preference flip algorithm, when market power is applied only on a subset of applicants. In each row, we consider a fraction of applicants over which market power can be applied (from 10 to 100 percent), and rule out the possibility to apply market power over other applicants even if they rank two contracts with the same program consecutively. We present the average result over 50 random draws of subsets of this size. Column 3 presents the increase in the number of assigned students relative to the benchmark (84,130).}" _n
file write sumstat "\end{tabular}" _n
file close sumstat
